Job های با دسترسی Sysadmin

Job های با دسترسی Sysadmin


SELECT j.[name] AS JobName, AllLogins.[name] AS JobOwner, j.date_created
FROM msdb.dbo.sysjobs AS J
    JOIN (
        -- Get all members of sysadmin
        SELECT L.[name], L.[sid]
        FROM sys.server_principals AS L
            JOIN sys.server_role_members AS RM
                ON L.principal_id = RM.member_principal_id
            JOIN sys.server_principals AS R
                ON RM.role_principal_id = R.principal_id
            WHERE R.[name] = 'sysadmin'

        UNION

        -- Control Server
        SELECT L.[name], L.[sid]
        FROM sys.server_principals AS L
            JOIN sys.server_permissions AS Perm
                ON L.principal_id = Perm.grantee_principal_id
            WHERE Perm.[type] = 'CL' AND Perm.[state] = 'G'
            ) AS AllLogins
        ON J.[owner_sid] = AllLogins.[sid]
WHERE j.date_created > DATEADD(DAY, -1, GETDATE());
سید حامد واحدی سید حامد واحدی     8 مهر 1396